import { Effect, Logger } from "effect";

const addSimpleLogger = Logger.replace(
  Logger.defaultLogger,
  // Custom logger implementation
  Logger.make(({ message }) => console.log(message)),
);

const program = Effect.gen(function* () {
  yield* Effect.log("Application started!");
  yield* Effect.log("Application is about to exit!");
});

// Running with the default logger
Effect.runFork(program);
/*
Output:
timestamp=... level=INFO fiber=#0 message="Application started!"
timestamp=... level=INFO fiber=#0 message="Application is about to exit!"
*/

// Overriding the default logger with a custom one
Effect.runFork(program.pipe(Effect.provide(addSimpleLogger)));
/*
Output:
[ 'Application started!' ]
[ 'Application is about to exit!' ]
*/
